home *** CD-ROM | disk | FTP | other *** search
- // Warning: This class is PRIVATE to the MiscFile class and may at a
- // later date be replaced with something more efficient, such as a
- // category on the "MiscDirectory" class... in other words, do NOT use
- // this class! If you do, don't complain to us if/when it disappears!
-
- // Copyright (C) 1995 Todd Thomas
-
- /************************************************************************
- CLASS: _MiscDirectoryStream
- INHERITS FROM: Object
- PROGRAMMER: Todd Thomas (todd@avocado.cuc.ab.ca)
- STARTED: May 1, 1994
- LAST CHANGED: May 25, 1994
- VERSION: 1.1
-
- CHANGES:
- 1.1
- Changed malloc and free to NX_MALLOC and NX_FREE. I was doing some
- odd malloc thing which seemed to work until you read alot of
- streams.
-
- This class is basically a wrapper for opendir, readdir, rewinddir, and
- closedir. It also makes use of stat(2) to get information about the
- current filename in the directory stream. Currently you can ask if the
- current file is a directory or a symbolic link. I may add more later.
-
- Please see the documentation for more information on what each method
- returns, etc.
-
- An example that prints all the files in /LocalApps:
-
- id dirStream = [ [DirectoryStream alloc] init];
-
-
- [dirStream openDir: "/LocalApps"];
-
- while ([dirStream readDir])
- printf ("%s\n", [dirStream filename]);
-
- [dirStream closeDir];
- [dirStream free];
-
- ************************************************************************/
-
- #import <sys/types.h>
- #import <sys/dir.h>
- #import <objc/Object.h>
-
-
- @interface _MiscDirectoryStream : Object
- {
- DIR *dirStream; // pointer to a directory stream
- struct direct *dp; // holds information about the current file
- char *currentDirName; // current directory being examined
- }
-
- - init;
- - initWithDirectory: (const char *)directory;
- - free;
-
-
- - openDir: (const char *)directory;
- - (const char *)directory;
- - readDir;
- - rewindDir;
- - closeDir;
-
- - (const char *)filename;
- - (int)filenameLength;
-
- - (BOOL)isADirectory;
- - (BOOL)isASymbolicLink;
-
- @end
-